package com.ruoyi.zhjd.laboratory.modules.laboratoryMechanicsYGroup.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.zhjd.laboratory.modules.laboratoryMechanicsYGroup.entity.MechanicsYDetailEntity;
import com.ruoyi.zhjd.laboratory.modules.laboratoryMechanicsYGroup.service.MechanicsYDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * 压力机数据
 */
@RestController
@RequestMapping("laboratory/mechanicsYDetail")
public class MechanicsYDetailController {

    @Autowired
    private MechanicsYDetailService mechanicsYDetailService;

    /**
     * 列表
     */
    @RequestMapping("/page")
//    //
    public R page(@RequestParam Map<String, Object> params) {
        IPage page = mechanicsYDetailService.queryPage(params);
        return R.ok(page);
    }


    /**
     * 信息
     */
    @RequestMapping("/find/{id}")
    //
    public R find(@PathVariable("id") Integer id) {
        MechanicsYDetailEntity mechanicsYDetail = mechanicsYDetailService.getInfo(id);
        return R.ok(mechanicsYDetail);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //
    public R save(@RequestBody MechanicsYDetailEntity mechanicsYDetail) {
        mechanicsYDetailService.saveData(mechanicsYDetail);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //
    public R update(@RequestBody MechanicsYDetailEntity mechanicsYDetail) {
        mechanicsYDetailService.updateData(mechanicsYDetail);
        return R.ok();
    }


    /**
     * 删除单个
     */
    @RequestMapping("/delete/{id}")
    //
    public R deleteOne(@PathVariable("id") Integer id) {
        mechanicsYDetailService.deleteOneData(id);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //
    public R delete(@RequestBody Integer[] ids) {
        mechanicsYDetailService.deleteData(Arrays.asList(ids));
        return R.ok();
    }
}
